package com.chenfan.mcn.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenfan.mcn.extension.Res;
import com.chenfan.mcn.model.McnPage;
import com.chenfan.mcn.model.StarAccountInfo;
import com.chenfan.mcn.service.StarAccountInfoService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 红人账户信息
 * @author tangwei
 * Date:     2021/2/1 9:52
 * Description: 红人账户信息
 */
@RestController
@RequestMapping("/star/account")
public class StarAccountInfoController {

    @Autowired
    private StarAccountInfoService starAccountInfoService;

    /**
     * 搜索红人账号信息
     * @param mcnPage
     * @param accountName
     * @param accountNumber
     * @param starId
     * @return
     */
    @GetMapping("/searchAccount")
    public Res<Page<StarAccountInfo>> searchAccount(@ApiIgnore McnPage<StarAccountInfo> mcnPage,
                                                    @RequestParam(required = false) String accountName,
                                                    @RequestParam(required = false) String accountNumber,
                                                    @RequestParam Long starId,
                                                    @RequestParam(required = false) Boolean filterInvalid) {
        return Res.ok(starAccountInfoService.searchAccount(mcnPage, accountName, accountNumber, starId, ObjectUtils.defaultIfNull(filterInvalid, Boolean.FALSE)));
    }
}